﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcmyjobs.Web.users
{
    public partial class userlogin : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Title = string.Format("个人管理中心：登陆   {0}", Application["webname"].ToString());

                this.lbl_time.Text = System.DateTime.Now.GetDateTimeFormats('D')[3].ToString();
            }
           
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // add by liuhui 如果企业登录则个人不能登录
                if (Session["enterprise_bid"] != null )
                {
                    Maticsoft.Common.MessageBox.Show(Page, "您已经登录单位账号。请先退出，才能登录个人账号！");
                    return;
                }
                string name = this.txtName.Text.Trim();
                string pwd = this.txtPwd.Text.Trim();
                string checkcode = this.txtCode.Text.Trim();
                if (Session["CheckCode"] != null)
                {
                    if (checkcode.ToUpper() == Session["CheckCode"].ToString())
                    {
                        lcmyjobs.BLL.user_basic bad = new BLL.user_basic();
                        string mname = "";
                        string time = "";
                        pwd = myPublic.GetMd5(pwd);
                        int id = bad.UserLogin(name, pwd, out mname, out time);
                        if (id != 0)
                        {
                            Session["user_id"] = id.ToString();
                            Session["user_name"] = mname;
                            Session["user_time"] = time;
                            Response.Redirect("user_main.html");
                        }
                        else
                            Maticsoft.Common.MessageBox.Show(this, "用户名或密码不对！");

                    }
                    else
                        Maticsoft.Common.MessageBox.Show(this, "验证码不对！");
                }
                else
                    Maticsoft.Common.MessageBox.Show(this, "验证码不对！");

            }
        }
    }
}